﻿Public Class frmPrincipal
    Public _usuarioLogado As New usuarioVO
    Public tamanho As Integer = 0
    Private _ucPreambulo As New ucPreambulo

    'Public Sub New()
    '    ' This call is required by the designer.
    '    InitializeComponent()
    '    _usuarioLogado = Login.Usuario.USUARIOLOGADO
    'End Sub

    'Public Property usuarioLogado As usuarioVO
    '    Get
    '        Return _usuarioLogado
    '    End Get
    '    Set(ByVal value As usuarioVO)
    '        value = _usuarioLogado
    '    End Set
    'End Property
    'Public Property getUcPreambulo As ucPreambulo
    '    Get
    '        Return _ucPreambulo
    '    End Get
    '    Set(ByVal value As ucPreambulo)

    '        value = _ucPreambulo
    '    End Set
    'End Property

    Private Sub frmPrincipal_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        frmLogin.Close()

        Dim valor As Integer = CType(System.Configuration.ConfigurationManager.AppSettings("countLock"), Integer)

        If (valor) > 0 Then
            valor = valor - 1
            generica.UpdateAppSettings("countLock", valor)
        End If
    End Sub

    Private Sub frmPrincipal_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not DesignMode Then
            carregaBarra()
        End If
    End Sub


    Private Sub carregaBarra()
        Try
            Dim L As New ToolStripLabel
            L.Text = "Seja bem vindo " & frmLogin.usuarioLogado.NOME & "/ Masp:" & frmLogin.usuarioLogado.MASP
            barraStatus.Items.Add(L)
            Me.WindowState = FormWindowState.Maximized
            tamanho = barraStatus.Height
        Catch ex As Exception
            generica.gravaErro(ex)
        End Try

    End Sub


    Private Sub SairToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SairToolStripMenuItem.Click
        Application.Exit()
    End Sub
    Private Sub ConsultarLaudosToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ConsultarLaudosToolStripMenuItem.Click

        Try

            Dim form As New frmConsultaLaudo
            generica.fechaForms(Me)
            form.MdiParent = Me
            form.Show()

        Catch ex As Exception

            generica.gravaErro(ex)

        End Try

    End Sub

    Public Function getLargura() As Integer

        Dim tamanho As Integer = 0

        Try

            tamanho = barraStatus.Height

        Catch ex As Exception

            generica.gravaErro(ex)
        End Try

        Return tamanho

    End Function

    Private Sub ConfiguracõesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ConfiguracõesToolStripMenuItem.Click

    End Sub

    Private Sub CadastrarSecãoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CadastrarSecãoToolStripMenuItem.Click

        Try

            Dim form As New frmConfigurarAplicacao
            generica.fechaForms(Me)
            form.MdiParent = Me
            form.Show()

        Catch ex As Exception

            generica.gravaErro(ex)

        End Try


    End Sub

    Private Sub MontarDadosRetiradosDoPCNETToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MontarDadosRetiradosDoPCNETToolStripMenuItem.Click
        Try
            Dim form As New frmMontaItensAvaliacao
            generica.fechaForms(Me)
            form.MdiParent = Me
            form.Show()
        Catch ex As Exception
            generica.gravaErro(ex)
        End Try
    End Sub

    Private Sub GerarLaudoAvaliaçãoDiretaindiretaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles avaDireta.Click

        Try
            Dim form As New frmAvaliacao
            form.EHDIRETA = True
            form.ucPreambulo.ID_NATUREZA = 52
            generica.fechaForms(Me)
            form.MdiParent = Me
            form.Show()
        Catch ex As Exception
            generica.gravaErro(ex)
        End Try
    End Sub

    Private Sub avaIndireta_Click(sender As Object, e As EventArgs) Handles avaIndireta.Click
        Try
            Dim form As New frmAvaliacao
            form.EHDIRETA = False
            form.ucPreambulo.ID_NATUREZA = 88
            generica.fechaForms(Me)
            form.MdiParent = Me
            form.Show()
        Catch ex As Exception
            generica.gravaErro(ex)
        End Try
    End Sub
    Private Sub MaconhaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MaconhaToolStripMenuItem.Click
        Try
            Dim form As New frmMaconha
            form.EHPRELIMINAR = True
            form.ehMaconha = True
            form.ehEcstasy = False
            form.ehCocaina = False
            form.ehCrack = False
            form.ucPreambulo.ID_NATUREZA = 68
            generica.fechaForms(Me)
            form.MdiParent = Me
            form.Show()
        Catch ex As Exception
            generica.gravaErro(ex)
        End Try
    End Sub

    Private Sub CocaínaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CocaínaToolStripMenuItem.Click
        Try
            Dim form As New frmMaconha
            form.EHPRELIMINAR = True
            form.ehMaconha = False
            form.ehCocaina = True
            form.ehEcstasy = False
            form.ehCrack = False
            form.ucPreambulo.ID_NATUREZA = 68
            generica.fechaForms(Me)
            form.MdiParent = Me
            form.Show()
        Catch ex As Exception
            generica.gravaErro(ex)
        End Try
    End Sub

    Private Sub CrackToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CrackToolStripMenuItem.Click
        Try
            Dim form As New frmMaconha
            form.EHPRELIMINAR = True
            form.ehMaconha = False
            form.ehCocaina = False
            form.ehEcstasy = False
            form.ehCrack = True
            form.ucPreambulo.ID_NATUREZA = 68
            generica.fechaForms(Me)
            form.MdiParent = Me
            form.Show()
        Catch ex As Exception
            generica.gravaErro(ex)
        End Try
    End Sub

    Private Sub EcstasyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EcstasyToolStripMenuItem.Click
        Try
            Dim form As New frmMaconha
            form.EHPRELIMINAR = True
            form.ehMaconha = False
            form.ehCocaina = False
            form.ehEcstasy = True
            form.ehCrack = False
            form.ucPreambulo.ID_NATUREZA = 68
            generica.fechaForms(Me)
            form.MdiParent = Me
            form.Show()
        Catch ex As Exception
            generica.gravaErro(ex)
        End Try
    End Sub

    Private Sub CNHFalsaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CNHFalsaToolStripMenuItem.Click
        Try
            Dim form As New frmCNH
            'form.EHCNHFALSA = True
            form.ucPreambulo.ID_NATUREZA = 13
            generica.fechaForms(Me)
            form.MdiParent = Me
            form.Show()
        Catch ex As Exception
            generica.gravaErro(ex)
        End Try
    End Sub

    Private Sub EliminarProcessosWordToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EliminarProcessosWordToolStripMenuItem.Click
        Try
            Dim form As New frmKillWord
            generica.fechaForms(Me)
            form.MdiParent = Me
            form.Show()
        Catch ex As Exception
            generica.gravaErro(ex)
        End Try
    End Sub
    Private Sub AbrirDiretorioNoQualOsLaudosEstaoArmazenadosToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AbrirDiretorioNoQualOsLaudosEstaoArmazenadosToolStripMenuItem.Click
        Try

            Dim path As String = System.Configuration.ConfigurationManager.AppSettings("dirLaudosWord")
            Dim diretorio As String = IO.Path.Combine(System.Windows.Forms.Application.StartupPath, path)
            ofdDiretorio.InitialDirectory = diretorio
            ofdDiretorio.ShowDialog()
            generica.visualizaWord(ofdDiretorio.FileName)
        Catch ex As Exception
            generica.gravaErro(ex)
        End Try
    End Sub
    Private Sub AlteraçãoDocumentalDeCNHToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AlteraçãoDocumentalDeCNHToolStripMenuItem.Click

        Try
            Dim form As New frmCNH
            'form.EHCNHFALSA = False
            form.ucPreambulo.ID_NATUREZA = 12
            generica.fechaForms(Me)
            form.MdiParent = Me
            form.Show()
        Catch ex As Exception
            generica.gravaErro(ex)
        End Try
    End Sub

   
    Private Sub ArmaDeFogoToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles armadeFogo.Click

        Try
            Dim form As New frmEficiencia
            form.EHARMA = True
            form.ucPreambulo.ID_NATUREZA = 36
            generica.fechaForms(Me)
            form.MdiParent = Me
            form.Show()
        Catch ex As Exception
            generica.gravaErro(ex)
        End Try

    End Sub

    Private Sub MuniçãoToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles MuniçãoToolStripMenuItem.Click
        Try
            Dim form As New frmEficienciaMunicao
            form.ucPreambulo.ID_NATUREZA = 81
            generica.fechaForms(Me)
            form.MdiParent = Me
            form.Show()
        Catch ex As Exception
            generica.gravaErro(ex)
        End Try
    End Sub
    '-----------------------------------------------------------
    ' REFERENTE A TRÂNSITO
    '----------------------------------------------------------
    'Private Sub VistoriaDeVeículoToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles VistoriaDeVeículoToolStripMenuItem.Click
    '    Try
    '        Dim form As New frmVeiculo
    '        form.ucPreambulo.ID_NATUREZA = 65
    '        generica.fechaForms(Me)
    '        form.MdiParent = Me
    '        form.Show()
    '    Catch ex As Exception
    '        generica.gravaErro(ex)
    '    End Try
    'End Sub

    'Private Sub VistoriaDeVeículoReferenteÀNaturezaDePATRIMÔNIOToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles VistoriaDeVeículoReferenteÀNaturezaDePATRIMÔNIOToolStripMenuItem.Click
    '    Try
    '        Dim form As New frmVeiculo
    '        form.ucPreambulo.ID_NATUREZA = 90
    '        generica.fechaForms(Me)
    '        form.MdiParent = Me
    '        form.Show()
    '    Catch ex As Exception
    '        generica.gravaErro(ex)
    '    End Try
    'End Sub

    Private Sub VersãoToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles VersãoToolStripMenuItem.Click
        Try
            Dim form As New frmSplash
            generica.fechaForms(Me)
            form.MdiParent = Me
            form.Show()
        Catch ex As Exception
            generica.gravaErro(ex)
        End Try
    End Sub

    Private Sub EixbirLogDeErroToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles EixbirLogDeErroToolStripMenuItem.Click
        Try
            Dim form As New frmLogErro
            generica.fechaForms(Me)
            form.MdiParent = Me
            form.Show()
        Catch ex As Exception
            generica.gravaErro(ex)
        End Try
    End Sub

    Private Sub VistoriaDeVeículoToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles vistoriatransito.Click
        Try
            Dim form As New frmVeiculo
            generica.fechaForms(Me)
            form.ucPreambulo.ID_TIPO_PERICIA = 14
            form.ucPreambulo.ID_NATUREZA = 65
            form.MdiParent = Me
            form.Show()
        Catch ex As Exception
            generica.gravaErro(ex)
        End Try
    End Sub

    Private Sub VistoriaDeVeículoReferenteÀNaturezaDePATRIMÔNIOToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles vistoriapatrimonio.Click
        Try
            Dim form As New frmVeiculo
            generica.fechaForms(Me)
            form.ucPreambulo.ID_TIPO_PERICIA = 12
            form.ucPreambulo.ID_NATUREZA = 90
            form.MdiParent = Me
            form.Show()
        Catch ex As Exception
            generica.gravaErro(ex)
        End Try
    End Sub




    Private Sub DeterminaçãoDeCalibreToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles DeterminaçãoDeCalibreToolStripMenuItem.Click
        Try
            Dim form As New frmDeterminacaoCalibre
            generica.fechaForms(Me)
            form.ucPreambulo.ID_TIPO_PERICIA = 5
            form.ucPreambulo.ID_NATUREZA = 35
            form.MdiParent = Me
            form.Show()
        Catch ex As Exception
            generica.gravaErro(ex)
        End Try
    End Sub

    Private Sub ArmaBrancaToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ArmaBrancaToolStripMenuItem.Click
        Try
            Dim form As New frmGeral
            generica.fechaForms(Me)
            form.ucPreambulo.ID_TIPO_PERICIA = 12
            form.ucPreambulo.ID_NATUREZA = 55
            form.EHARMABRANCA = True
            form.MdiParent = Me
            form.Show()
        Catch ex As Exception
            generica.gravaErro(ex)
        End Try
    End Sub

    Private Sub LaudoGeralToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles LaudoGeralToolStripMenuItem.Click
        Try
            Dim form As New frmGeral
            generica.fechaForms(Me)
            form.ucPreambulo.ID_TIPO_PERICIA = -1
            form.ucPreambulo.ID_NATUREZA = -1
            form.EHARMABRANCA = False
            form.MdiParent = Me
            form.Show()
        Catch ex As Exception
            generica.gravaErro(ex)
        End Try
    End Sub

    Private Sub MontarDadosDoCondutorToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles MontarDadosDoCondutorToolStripMenuItem.Click

        Try
            Dim form As New frmMontaDadosCondutor
            generica.fechaForms(Me)
            form.MdiParent = Me
            form.Show()
        Catch ex As Exception
            generica.gravaErro(ex)
        End Try
    End Sub

    Private Sub InformaticaMenuItem_Click(sender As Object, e As EventArgs) Handles InformaticaMenuItem.Click
      
    End Sub

    Private Sub TranscriçãoDeCelularesToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles TranscriçãoDeCelularesToolStripMenuItem.Click
        Try
            Dim form As New frmCelular
            generica.fechaForms(Me)
            form.ucPreambulo.ID_TIPO_PERICIA = 9
            form.ucPreambulo.ID_NATUREZA = 44
            form.MdiParent = Me
            form.Show()
        Catch ex As Exception
            generica.gravaErro(ex)
        End Try
    End Sub

    Private Sub ConstataçãoPreliminarToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ConstataçãoPreliminarToolStripMenuItem.Click
        Try
            Dim form As New frmConstatacaoPreliminar(False)
            form.EHPRELIMINAR = True
            form.ucPreambulo.ID_TIPO_PERICIA = 16
            form.ucPreambulo.ID_NATUREZA = 68
            generica.fechaForms(Me)
            form.MdiParent = Me
            form.Show()
        Catch ex As Exception
            generica.gravaErro(ex)
        End Try

    End Sub

    Private Sub ExameDefinitivoToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ExameDefinitivoToolStripMenuItem.Click
        Try
            Dim form As New frmDefinitivo
            form.EHPRELIMINAR = True
            form.ucPreambulo.ID_TIPO_PERICIA = 16
            form.ucPreambulo.ID_NATUREZA = 73
            ' form.ucPreambulo._ehExibirBotaoDefinitivo = True
            generica.fechaForms(Me)
            form.MdiParent = Me
            form.Show()
        Catch ex As Exception
            generica.gravaErro(ex)
        End Try
    End Sub

    Private Sub ToxicológicoDefinitivoRecebidoViaTCOToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ToxicológicoDefinitivoRecebidoViaTCOToolStripMenuItem.Click
        Try
            Dim form As New frmConstatacaoPreliminar(True)
            form.EHPRELIMINAR = True
            form.ucPreambulo.ID_TIPO_PERICIA = 16
            form.ucPreambulo.ID_NATUREZA = 73
            generica.fechaForms(Me)
            form.MdiParent = Me
            form.Show()
        Catch ex As Exception
            generica.gravaErro(ex)
        End Try
    End Sub

    Private Sub CLRVFalsoToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles CLRVFalsoToolStripMenuItem.Click
        Try
            Dim form As New frmCLRV
            form.ucPreambulo.ID_NATUREZA = 13
            form.tipoExame = 0
            generica.fechaForms(Me)
            form.MdiParent = Me
            form.Show()
        Catch ex As Exception
            generica.gravaErro(ex)
        End Try
    End Sub

    Private Sub CRLVAutênticoEmitidoIrregularmenteToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles CRLVAutênticoEmitidoIrregularmenteToolStripMenuItem.Click
        Try
            Dim form As New frmCLRV
            form.ucPreambulo.ID_NATUREZA = 13
            form.tipoExame = 3
            generica.fechaForms(Me)
            form.MdiParent = Me
            form.Show()
        Catch ex As Exception
            generica.gravaErro(ex)
        End Try
    End Sub

    Private Sub CLToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles CLToolStripMenuItem.Click
        Try
            Dim form As New frmCLRV
            form.ucPreambulo.ID_NATUREZA = 13
            form.tipoExame = 4
            generica.fechaForms(Me)
            form.MdiParent = Me
            form.Show()
        Catch ex As Exception
            generica.gravaErro(ex)
        End Try
    End Sub

    Private Sub CRLVAutênticoComAlteraçãoDocumentalToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles CRLVAutênticoComAlteraçãoDocumentalToolStripMenuItem.Click
        Try
            Dim form As New frmCLRV
            form.ucPreambulo.ID_NATUREZA = 12
            generica.fechaForms(Me)
            form.MdiParent = Me
            form.Show()
        Catch ex As Exception
            generica.gravaErro(ex)
        End Try
    End Sub

    Private Sub CédulaFalsaToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles CédulaFalsaToolStripMenuItem.Click
        Try
            Dim form As New frmPapelMoeda
            form.ucPreambulo.ID_NATUREZA = 13
            form.ehFalso = True
            generica.fechaForms(Me)
            form.MdiParent = Me
            form.Show()
        Catch ex As Exception
            generica.gravaErro(ex)
        End Try
    End Sub

    Private Sub CédulaAurtênticaToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles CédulaAurtênticaToolStripMenuItem.Click
        Try
            Dim form As New frmPapelMoeda
            form.ucPreambulo.ID_NATUREZA = 13
            form.ehFalso = False
            generica.fechaForms(Me)
            form.MdiParent = Me
            form.Show()
        Catch ex As Exception
            generica.gravaErro(ex)
        End Try
    End Sub

End Class